#define  _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <string.h>

#define MAX_LEN 80

void findLCS(char* X, char* Y, int m, int n, int dp[MAX_LEN + 1][MAX_LEN + 1], char* lcs, int index) {
    if (m == 0 || n == 0) {
        printf("%s\n", lcs);
        return;
    }

    if (X[m - 1] == Y[n - 1]) {
        lcs[index - 1] = X[m - 1];
        findLCS(X, Y, m - 1, n - 1, dp, lcs, index - 1);
    }
    else {
        if (dp[m - 1][n] >= dp[m][n - 1]) {
            findLCS(X, Y, m - 1, n, dp, lcs, index);
        }
        if (dp[m][n - 1] >= dp[m - 1][n]) {
            findLCS(X, Y, m, n - 1, dp, lcs, index);
        }
    }
}

void LCS(char* X, char* Y) {
    int m = strlen(X);
    int n = strlen(Y);
    int dp[MAX_LEN + 1][MAX_LEN + 1];

    // Initialize dp array
    for (int i = 0; i <= m; i++) {
        for (int j = 0; j <= n; j++) {
            if (i == 0 || j == 0)
                dp[i][j] = 0;
            else if (X[i - 1] == Y[j - 1])
                dp[i][j] = dp[i - 1][j - 1] + 1;
            else
                dp[i][j] = (dp[i - 1][j] > dp[i][j - 1]) ? dp[i - 1][j] : dp[i][j - 1];
        }
    }

    // Find all LCS
    char lcs[MAX_LEN + 1];
    lcs[dp[m][n]] = '\0';
    findLCS(X, Y, m, n, dp, lcs, dp[m][n]);
}

int main() {
    char X[MAX_LEN + 1], Y[MAX_LEN + 1];
    scanf("%s", X);
    scanf("%s", Y);

    LCS(X, Y);

    return 0;
}